<?php
//Arquivo de verificacão de campos

require("php/config.php");
require("php/postgres.php");

try {

	if (!empty($_GET["type"]) && !empty($_GET["value"])) {
		
		$confs = $GLOBALS["CONFIGS"]["PSQL_DB"];
		$pgcon = new PostgresConnection($confs["HOST"], $confs["PORT"], $confs["USER"], $confs["PASSWORD"], $confs["DATABASE"]);
		$type = $_GET["type"];
		$value = $_GET["value"];
		switch ($type) {
		
			case "1": //E-mail
			
				if ($pgcon->isValidEmail($value)) {
					
					die("1");
				} else {
				
					die("0");
				}
				break;
				
			case "2": //Login
			
				if ($pgcon->isValidLogin($value)) {
					
					die("1");
				} else {
				
					die("0");
				}
				break;
		}
	}
} catch (PostgresConnectionException $pce) {
	//Nothing
}
echo 0;
?>